﻿<%@ Page Language="C#" MasterPageFile="~/Site.master" CodeBehind="DefaultMenu.aspx.cs"
    Inherits="sistemaAcademicoFinanceiroEscolas.DefaultMenuDiretoriaInformatica" %>

<%@ Register Src="~/DynamicData/Content/GridViewPager.ascx" TagName="GridViewPager"
    TagPrefix="asp" %>
<%@ Register Src="~/DynamicData/Content/FilterUserControl.ascx" TagName="DynamicFilter"
    TagPrefix="asp" %>
<%@ Register Assembly="Catalyst.Web.DynamicData" Namespace="Catalyst.Web.DynamicData"
    TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:DynamicDataManager ID="DynamicDataManager1" runat="server" AutoLoadForeignKeys="true" />
    <head>
    </head>
    <body>
        <table width="100%" style="background-color: #f6f9fc;">
            <tr>
                <td width="35%" style="background-color: #f6f9fc;" align="center" valign="top">
                    <br />
                    <div style="height: 100px; overflow-y: auto;">
                        <table width="100%" style="background-color: #f6f9fc; font-size: larger;" border="1"
                            cellpadding="10" cellspacing="0" bordercolor="#99CCFF">
                            <tr style="background-color: #f6f9fc;">
                                <th colspan="3">
                                    Aniversariantes
                                </th>
                            </tr>
                            <tr style="background-color: #f6f9fc;">
                                <th>
                                    Nome
                                </th>
                                <th>
                                    Data
                                </th>
                                <th>
                                    Idade
                                </th>
                            </tr>
                            <%
                            
                            
                                System.Data.SqlClient.SqlConnection sqlc = new System.Data.SqlClient.SqlConnection(ConfigurationManager.AppSettings["baseDados"]);
                                sqlc.Open();

                                string select = "select * from aluno where SUBSTRING(dataNascimentoAluno, 0, 6) = '" + DateTime.Now.ToString("dd/MM") + "' order by nomeAluno";


                                System.Data.SqlClient.SqlCommand cmdDetalhe = new System.Data.SqlClient.SqlCommand(select, sqlc);
                                System.Data.SqlClient.SqlDataReader myReaderDetalhe = cmdDetalhe.ExecuteReader();


                                if (myReaderDetalhe.HasRows)
                                {
                                    while (myReaderDetalhe.Read())
                                    {
                            %>
                            <tr align="center" style="background-color: #f6f9fc;">
                                <td>
                                    <%=myReaderDetalhe["nomeAluno"].ToString() %>
                                </td>
                                <td>
                                    <%=myReaderDetalhe["dataNascimentoAluno"].ToString()%>
                                </td>
                                <td><%--<%=DateTime.Now.ToString("dd/MM/yyyy") %>--%>
                                    <%--<%=calculaIdade(Convert.ToDateTime(myReaderDetalhe["dataNascimentoAluno"]))%>--%>
                                    <%=calculaIdade(Convert.ToInt16(myReaderDetalhe["dataNascimentoAluno"].ToString().Substring(0, 2)), Convert.ToInt16(myReaderDetalhe["dataNascimentoAluno"].ToString().Substring(3, 2)), Convert.ToInt16(myReaderDetalhe["dataNascimentoAluno"].ToString().Substring(6, 4)))%>
                                </td>
                            </tr>
                            <%
                                }
                            }

                            myReaderDetalhe.Close();
                            
                            %>
                        </table>
                    </div>
                    <br />
                    <div style="height: 300px; overflow-y: auto;">
                        <table width="100%" style="background-color: #f6f9fc; font-size: larger;" border="1"
                            cellpadding="10" cellspacing="0" bordercolor="#99CCFF">
                            <tr style="background-color: #f6f9fc;">
                                <th colspan="4">
                                    Aulas de hoje -
                                    <%=DateTime.Now.ToString("dd/MM/yyyy")%>
                                </th>
                            </tr>
                            <tr style="background-color: #f6f9fc;">
                                <th>
                                    Aluno / Grupo
                                </th>
                                <th>
                                    Professor
                                </th>
                                <th>
                                    Disciplina
                                </th>
                                <th>
                                    Horário
                                </th>
                            </tr>
                            <%

                                select = "select ";
                                select += "(select descricaoDisciplina from disciplina where disciplina.codigoDisciplina = aula.codigoDisciplina) as disciplina,  ";
                                select += "(select nomeProfessor from professor where professor.codigoProfessor = aula.codigoProfessor) as professor,  ";
                                select += "(select nomeAluno from aluno where aluno.codigoAluno = aula.codigoAluno) as aluno,  ";
                                select += "(select nomeGrupo from grupo where grupo.codigoGrupo = aula.codigoGrupo) as grupo,  ";
                                select += "aula.* from aula where dataAula = '" + DateTime.Now.ToString("dd/MM/yyyy") + "'";


                                cmdDetalhe = new System.Data.SqlClient.SqlCommand(select, sqlc);
                                myReaderDetalhe = cmdDetalhe.ExecuteReader();

                                string nome = "";

                                if (myReaderDetalhe.HasRows)
                                {
                                    while (myReaderDetalhe.Read())
                                    {
                                        if (myReaderDetalhe["aluno"].ToString() != "")
                                        {
                                            nome = "Aluno: " + myReaderDetalhe["aluno"].ToString();
                                        }
                                        else
                                        {
                                            nome = "Grupo: " + myReaderDetalhe["grupo"].ToString();
                                        }
                            %>
                            <tr align="center" style="background-color: #f6f9fc;">
                                <td>
                                    <%=nome %>
                                </td>
                                <td>
                                    <%=myReaderDetalhe["professor"].ToString()%>
                                </td>
                                <td>
                                    <%=myReaderDetalhe["disciplina"].ToString()%>
                                </td>
                                <td>
                                    <%=myReaderDetalhe["horaInicialAula"].ToString()%>
                                    às
                                    <%=myReaderDetalhe["horaFinalAula"].ToString()%>
                                </td>
                            </tr>
                            <%
                                }
                                }

                                myReaderDetalhe.Close();

                                sqlc.Close();
                            
                            %>
                        </table>
                    </div>
                </td>
                <td width="65%" align="center" style="background-color: #f6f9fc;">
                    <img src="images/LogoSBF2.png" width="700" height="500" />
                </td>
            </tr>
        </table>
    </body>
</asp:Content>
